var default_fontSize = '1.0rem';
var legend_font_size = '1.0rem';
var barMaxWidth = 72;
var default_color = "#fff";
var theme_color = "#2ec7c9";
var show_title = true;
var default_align = 'center';
var default_rotate = '0';
var default_90_rotate = '-90';
var default_position = 'inside';
var default_animationDuration = 2000;
var default_animationDurationUpdate = 2000;
var default_textLabelnum = 20;
var default_bar_color = new echarts.graphic.LinearGradient(0, 0, 0, 1, [{ offset: 0, color: '#06b5d7' }, { offset: 0.5, color: '#44c0c1' }, { offset: 1, color: '#71c8b1' }]);

var chartoption = {

	map2:function(selectname){
		var jiedao=["云林街道","厚桥街道","东港镇","锡北镇","鹅湖镇","羊尖镇","东北塘街道","安镇街道","东亭街道"];
			
		var regions=[];
		for(var i=0;i<jiedao.length;i++){
			var item={name:jiedao[i],selected:selectname==jiedao[i]?true:false,itemStyle:{
						emphasis: { areaColor: '#ffc107', borderWidth: 0 }
                			},
						};
						regions[i]=item;
		}
		
				
	
		var options = {
            grid: { height: '100%', top: -20, width: '100%' },
            title: { show: false },
            legend: { show: false },
            geo: {
                //selectedMode: 'single',
                label: {
                    show: true,
					fontSize:'1.6rem',
                    color: "#fff",
                },
                itemStyle: {
                    areaColor: {
                        type: 'radial',
                        x: 0.5,
                        y: 0.5,
                        r: 0.8,
                        colorStops: [{ offset: 0, color: 'rgba(147, 235, 248, 0)' }, { offset: 1, color: 'rgba(20, 184, 210, .2)' }],
                        globalCoord: false
                    },
                    borderColor: 'rgba(147, 235, 248, 1)',
                    borderWidth: 1,
                    shadowColor: 'rgba(128, 217, 248, 1)',
                    shadowOffsetX: -2,
                    shadowOffsetY: 2,
                    shadowBlur: 10,
                    emphasis: { areaColor: '#ffc107', borderWidth: 0 }
                },
                regions: regions
            },
            // visualMap: { show: false, min: 0, max: 0, inRange: { color: [] } },
            // tooltip: { trigger: 'axis', axisPointer: { type: 'shadow', shadowStyle: { color: '#fff' } } },
            animation: true,
            series: [{ colorBy: 'data', symbol: 'pin', symbolSize: [20, 50] }]
        };
		return options;
	
	},
	map:function(){
	    var options = {
            grid: { height: '100%', top: -20, width: '100%' },
            title: { show: false },
            legend: { show: false },
            geo: {
                //selectedMode: 'single',
                label: {
                    show: true,
					fontSize:'1.6rem',
                    color: "#fff",
                },
                itemStyle: {
                    areaColor: {
                        type: 'radial',
                        x: 0.5,
                        y: 0.5,
                        r: 0.8,
                        colorStops: [{ offset: 0, color: 'rgba(147, 235, 248, 0)' }, { offset: 1, color: 'rgba(20, 184, 210, .2)' }],
                        globalCoord: false
                    },
                    borderColor: 'rgba(147, 235, 248, 1)',
                    borderWidth: 1,
                    shadowColor: 'rgba(128, 217, 248, 1)',
                    shadowOffsetX: -2,
                    shadowOffsetY: 2,
                    shadowBlur: 10,
                    emphasis: { areaColor: '#ffc107', borderWidth: 0 }
                },
               
            },
            // visualMap: { show: false, min: 0, max: 0, inRange: { color: [] } },
            // tooltip: { trigger: 'axis', axisPointer: { type: 'shadow', shadowStyle: { color: '#fff' } } },
            animation: true,
            series: [{ colorBy: 'data', symbol: 'pin', symbolSize: [20, 50] },
			         {
                            type: 'effectScatter',
							itemStyle: {
                                normal: {
                                    color:function(params){  //根据不同数据显示不同颜色的标记
                                   // console.log("------",params)
                                        if (params.seriesName=="镇街道") {
                                            return '#0efcff';
                                        } 
										if (params.seriesName=="县区") {
                                            return '#00ff00';
                                        } else{
                                            return '#ff8c00';
                                        }
                                    },
                                    // color: '#f4e925',
                                    shadowBlur: 10,
                                    shadowColor: '#333'
                                }
                            },
					}]
        };
		return options;
	},
    text_box: function(namecolor, nameSize, showtitle, valueColor, valueSize) {
        var param = {
            label: {
                name: {
                    show: showtitle ? true : false,
                    color: namecolor,
                    fontSize: nameSize,
                    formatter: function(val) {
                        var strs = val.split('');
                        var str = '';
                        for (var i = 0, s; s = strs[i++];) {
                            str += s;
                            if (!(i % default_textLabelnum)) {
                                str += '\n';
                            }
                        }
                        return str
                    }
                },
                value: {
                    color: valueColor,
                    fontWeight: 'bold',
                    fontSize: valueSize,
                    valueAlign: default_align,
                    animation: true,
                    animateStartNum: 0,
                    animationDuration: 3000
                },
            }
        };
        return param;
    },
    text_box2: function(namecolor, nameSize, textLabelnum, showtitle, valueColor, valueSize) {
        var param = {
            label: {
                name: {
                    show: showtitle ? true : false,
                    color: namecolor,
                    fontSize: nameSize,
                    formatter: function(val) {
                        var strs = val.split('');
                        var str = '';
                        for (var i = 0, s; s = strs[i++];) {
                            str += s;
                            if (!(i % textLabelnum || default_textLabelnum)) {
                                str += '\n';
                            }
                        }
                        return str
                    }
                },
                value: {
                    color: valueColor,
                    fontWeight: 'bold',
                    fontSize: valueSize,
                    valueAlign: default_align,
                    animation: true,
                    animateStartNum: 0,
                    animationDuration: 3000
                },
            }
        };
        return param;
    },
    barh: function(num, barWidthsize, labelSize, rotate, axisLabelFoneSize, axisLabelnum, istheme) {
        var items = new Array();
        for (var i = 0; i < num; i++) {
            var item = {
                center: ['55%', '55%'],
				barGap:'100%',
				barcategoryGap:'20%',
                barWidth: barWidthsize,
                barMaxWidth: barMaxWidth,
                itemStyle: {
                    barBorderRadius: [0, 25,25, 0],
                    color: istheme ? "auto" : default_bar_color,
                },
                label: {
                    normal: {
                        show: true,
                        align: default_align,
                        color: default_color,
						verticalAlign:"middle",
                        rotate: istheme ? default_90_rotate : "0",
                        fontSize: labelSize,
                        position: "right",
                        distance: 60,
                    },

                    animation: true,
                    animationDuration: default_animationDuration,
                    animationTypeUpdate: 'expansion',
                    animationDurationUpdate: default_animationDurationUpdate
                }
            };
            items.push(item);
        }

        var chartOptionHorizontal = {
            grid: {
                height: '85%',
                top: '15%',
                width: '80%',
                right: '20%'
            },
            title: {
                show: false
            },
            yAxis: {
                axisLabel: {
                    color: default_color,
                    fontSize: axisLabelFoneSize,
                    formatter: function(val) {
                        var strs = val.split('');
                        var str = '';
                        for (var i = 0, s; s = strs[i++];) {
                            str += s;
                            if (!(i % axisLabelnum)) {
                                str += '\n';
                            }
                        }
                        return str
                    }
                },
                splitLine: {
                    show: false
                },
                axisLine: {
                    show: false
                },
                axisTick: {
                    show: false
                },
                nameTextStyle: {
                    show: false,
                    color: 'transparent',
                    fontSize: 14
                }
            },
            xAxis: {
                show: false,
                axisLabel: {
                    color: default_color,
                    fontSize: axisLabelFoneSize,
                },
                splitLine: {
                    show: false
                },
                axisLine: {
                    show: false
                },
                axisTick: {
                    show: false
                }
            },
            legend: {
                show: istheme ? true : false,
                textStyle: {
                    fontSize: legend_font_size,
                    color: default_color
                }
            },
            series: items
        };
        return chartOptionHorizontal;
    },
    barn: function(num, barWidthsize, labelSize, rotate, axisLabelFoneSize, axisLabelnum, istheme) {
        var items = new Array();
        for (var i = 0; i < num; i++) {
            var item = {
                center: ['55%', '55%'],
				barGap:'100%',
				barcategoryGap:'20%',
                barWidth: barWidthsize,
                barMaxWidth: barMaxWidth,
                itemStyle: {
                    barBorderRadius: [5, 5, 0, 0],
                    color: istheme ? "auto" : default_bar_color,
                },
                label: {
                    normal: {
                        show: true,
                        align: default_align,
                        color: default_color,
                        rotate:  "0",
                        fontSize: labelSize,
                        position:  "top"
                    },

                    animation: true,
                    animationDuration: default_animationDuration,
                    animationTypeUpdate: 'expansion',
                    animationDurationUpdate: default_animationDurationUpdate
                }
            };
            items.push(item);
        }

        var chartOption = {
            grid: {
                height: num>1?'80%':'80%',
                top: num>1?'15%':'15%',
                width: '100%',
                right: '0',
                left: '-20'
            },
            title: {
                show: false
            },
            yAxis: {
                show: false,
                axisLabel: {
                    color: default_color,
                    fontSize: legend_font_size,
                },
                splitLine: {
                    show: true
                },
                axisLine: {
                    show: true
                },
                axisTick: {
                    show: false
                },
                nameTextStyle: {
                    color: default_color,
                    fontSize: axisLabelFoneSize
                }
            },
            xAxis: {
                name: '',
                axisLabel: {
                    color: default_color,
                    rotate: rotate || default_rotate,
                    fontSize: axisLabelFoneSize,
                    formatter: function(val) {
                        var strs = val.split('');
                        var str = '';
                        for (var i = 0, s; s = strs[i++];) {
                            str += s;
                            if (!(i % axisLabelnum)) {
                                str += '\n';
                            }
                        }
                        return str
                    }
                },
                splitLine: {
                    show: false
                },
                axisLine: {
                    show: true
                },
                axisTick: {
                    show: false
                }
            },
            legend: {
                show: istheme ? true : false,
                textStyle: {
                    fontSize: legend_font_size,
                    color: default_color
                }
            },
            series: items
        };

        return chartOption;
    },

    line: function(num, lineWidthsize, type, linecolor, rotate, labelSize, axisLabelFoneSize, axisLabelnum) {
        var items = new Array();
        for (var i = 0; i < num; i++) {
            var item = {
                label: {
                    normal: {
                        show: true,
                        align: default_align,
                        color: default_color,
                        rotate: rotate || default_rotate,
                        fontSize: labelSize,
                        position: 'top'
                    },
                    animation: true,
                    animationDuration: default_animationDuration,
                    animationTypeUpdate: 'expansion',
                    animationDurationUpdate: default_animationDurationUpdate
                },
                lineStyle: {
                    width: lineWidthsize,
                    type: type,
                    color: linecolor,
                },
                itemStyle: {},
            };

            items.push(item);
        }


        var linechartOption = {
            grid: {
                height: '85%',
                top: '15%',
                width: '90%',
                right: '10%'
            },
            title: {
                show: false
            },
            yAxis: {
                show: false,
                axisLabel: {
                    color: default_color,
                    fontSize: legend_font_size,
                },
                splitLine: {
                    show: true
                },
                axisLine: {
                    show: false
                },
                axisTick: {
                    show: false
                },
                nameTextStyle: {
                    color: default_color,
                    fontSize: 14
                }
            },
            xAxis: {
                name: '',
                axisLabel: {
                    color: default_color,
                    fontSize: axisLabelFoneSize,
                    formatter: function(val) {
                        var strs = val.split('');
                        var str = '';
                        for (var i = 0, s; s = strs[i++];) {
                            str += s;
                            if (!(i % axisLabelnum)) {
                                str += '\n';
                            }
                        }
                        return str
                    }
                },
                splitLine: {
                    show: false
                },
                axisLine: {
                    show: true
                },
                axisTick: {
                    show: false
                }
            },
            legend: {
                show: false,
                textStyle: {
                    fontSize: legend_font_size,
                    color: default_color
                }
            },
            series: items
        };

        return linechartOption;
    },

    redar: function() {
        var redarOption = {
            'grid': {
                'height': '85%',
                'top': '15%',
                'width': '95%',
                'right': '5%'
            },
            'title': {
                'show': false
            },
            'yAxis': {
                'show': false,
                'axisLabel': {
                    'color': default_color,
                    'fontSize': default_fontSize
                },
                'splitLine': {
                    'show': true
                },
                'axisLine': {
                    'show': false
                },
                'axisTick': {
                    'show': false
                },
                'nameTextStyle': {
                    'color': default_color,
                    'fontSize': 14
                }
            },
            'xAxis': {
                'axisLabel': {
                    'color': default_color,
                    'fontSize': legend_font_size
                },
                'splitLine': {
                    'show': false
                },
                'axisLine': {
                    'show': false
                },
                'axisTick': {
                    'show': false
                }
            },
            'legend': {
                'show': false,
                'textStyle': {
                    'fontSize': legend_font_size,
                    'color': default_color
                }
            },
            'series': [{

                'itemStyle': {},
                animation: true,
                animationDuration: default_animationDuration,
                animationTypeUpdate: 'expansion',
                animationDurationUpdate: default_animationDurationUpdate,
                'label': {
                    'normal': {
                        'show': true,
                        'align': default_align,
                        'color': default_color,
                        'fontSize': default_fontSize,
                        'rotate': '0',
                        'position': 'outside',
                        'offset': [0, 0]
                    },
                    'emphasis': {
                        'show': false,
                        'color': '#ff8c00',
                        'backgroundColor': 'transparent',
                        'fontSize': default_fontSize,
                        'formatter': '{b}({c}%)'
                    }
                }
            }]
        };
    },
    pie: function(labelFontSize) {

        var pieOption = {
            'grid': {
                'height': '85%',
                'top': '15%',
                'width': '65%',
                'right': '5%'
            },
            'title': {
                'show': true,
				"textStyle":{
					color:'#0efcff',
					fontSize:'1.6rem'
				}
				
            },
            'yAxis': {
                'show': false,
                'axisLabel': {
                    'color': default_color,
                    'fontSize': labelFontSize
                },
                'splitLine': {
                    'show': true
                },
                'axisLine': {
                    'show': false
                },
                'axisTick': {
                    'show': false
                },
                'nameTextStyle': {
                    'color': default_color,
                    'fontSize': labelFontSize ? default_fontSize : labelFontSize
                }
            },
            'xAxis': {
                'axisLabel': {
                    'color': default_color,
                    'fontSize': labelFontSize ? default_fontSize : labelFontSize
                },
                'splitLine': {
                    'show': false
                },
                'axisLine': {
                    'show': false
                },
                'axisTick': {
                    'show': false
                }
            },
            'legend': {
                'show': false,
                'textStyle': {
                    'fontSize': default_fontSize,
                    'color': default_color
                }
            },
            'series': [{
                'itemStyle': {},
                animation: true,
                animationDuration: default_animationDuration,
                animationTypeUpdate: 'expansion',
                animationDurationUpdate: default_animationDurationUpdate,
                'label': {
                    'normal': {
                        'show': true,
                        'align': default_align,
                        'color': default_color,
                        'fontSize': '1.4rem',
                        'rotate': '0',
                        'position': 'outside',
                        'offset': [0, 0],
                        'alignTo': 'edge',
                        'edgeDistance': '0%'
                    },
					formatter: '{b}: {d}',
					
                }
            }]
        };
        return pieOption;
    },
    pie2: function(labelFontSize) {

        var pieOption = {
            'grid': {
                'height': '85%',
                'top': '15%',
                'width': '95%',
                'right': '5%'
            },
            'title': {
                'show': false
            },
            'yAxis': {
                'show': false,
                'axisLabel': {
                    'color': default_color,
                    'fontSize': default_fontSize
                },
                'splitLine': {
                    'show': true
                },
                'axisLine': {
                    'show': false
                },
                'axisTick': {
                    'show': false
                },
                'nameTextStyle': {
                    'color': default_color,
                    'fontSize': labelFontSize ? default_fontSize : labelFontSize
                }
            },
            'xAxis': {
                'axisLabel': {
                    'color': default_color,
                    'fontSize': labelFontSize ? default_fontSize : labelFontSize
                },
                'splitLine': {
                    'show': false
                },
                'axisLine': {
                    'show': false
                },
                'axisTick': {
                    'show': false
                }
            },
            'legend': {
                'show': false,
                'textStyle': {
                    'fontSize': default_fontSize,
                    'color': default_color
                }
            },
            'series': [{
                'itemStyle': {},
                animation: true,
                animationDuration: default_animationDuration,
                animationTypeUpdate: 'expansion',
                animationDurationUpdate: default_animationDurationUpdate,
                'label': {
                    'normal': {
                        'show': true,
                        'align': default_align,
                        'color': default_color,
                        'fontSize': labelFontSize ? default_fontSize : labelFontSize,
                        'rotate': '0',
                        'position': 'outside',
                        'offset': [0, 0],
                        'alignTo': 'edge',
                        'edgeDistance': '10%'
                    },

                }
            }]
        };
        return pieOption;
    },
    table: function(maxTextNum) {
        var tableOption = {
            title: {
                show: false
            },
            carousel: {
                 enable: true,
               pauseOnHover: true
             },
            table: {
                header: {
                    color: theme_color,
                    backgroundColor: 'transparent'
                },
                autoWidth: true,
                autoFill: true,
                row: {
                    hover: {
                        color: default_color,
                        backgroundColor: '#2ec7c9'
                    },
                    odd: {
                        color: default_color,
                        backgroundColor: 'transparent'
                    },
                    even: {
                        color: default_color,
                        backgroundColor: 'transparent'
                    },
                    selected: {
                        color: default_color,
                        backgroundColor: 'transparent'
                    }
                },
                renderValue: function(value, name, rowIndex, columnIndex, row) {
                    if (value != null) {
                        if (value.length > maxTextNum) {
                            value = value.slice(0, maxTextNum) + '...';
                        }
                    }
                    return value;
                }
            }
        };

        return tableOption;

    }
}